package com.dingding.order.facade;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dingding.order.code.order.PublishCarType;
import com.dingding.order.core.cancel.biz.ICancelOrderService;
import com.dingding.order.core.confirm.biz.IConfirmArriveService;
import com.dingding.order.core.grab.biz.IGrabOrderService;
import com.dingding.order.core.history.service.IHistoryOrderService;
import com.dingding.order.service.ICarOrderFacade;

/**
 * 
* @ClassName: CarOrderFacade.java 
* @Package com.dingding.order.facade 
* @Description: 对外暴露司机订单接口
* @author hufan
* @date 2016年11月21日 下午4:47:56 
* @version V2.5.6
 */
@Component("carOrderFacade")
public class CarOrderFacade implements ICarOrderFacade {

	//确认到大相关
	@Resource(name = "taxiConfirmArriveService")
	private IConfirmArriveService taxiConfirmArriveService;
	
	//历史订单相关
	@Resource(name = "driverOrderService")
	private IHistoryOrderService driverOrderService;
	
	//抢单相关
	@Resource(name = "taxiGrabOrderService")
	private IGrabOrderService taxiGrabOrderService;
	
	@Resource(name = "specialGrabOrderService")
	private IGrabOrderService specialGrabOrderService;
	
	//取消订单相关
	@Resource(name = "taxiCancelOrderService")
	private ICancelOrderService taxiCancelOrderService;
	
	@Resource(name = "specialCancelOrderService")
	private ICancelOrderService specialCancelOrderService;
	
	/**
	* @Description:taxi司机到达接口
	* @author hufan
	* @since 2.5.6
	*/
	@Override
	public String taixConfirmArrive(String requestData) {
		return taxiConfirmArriveService.confirmArrive(requestData);
	}
	
	/**
	 * @Description:获取司机的历史订单
	 * @author fengshuonan
	 * @since 2.4
	 */
	@Override
	public String getDriverHistoryOrdersByCarType(String clientData, PublishCarType carType) {
		return driverOrderService.getHistoryOrdersByCarType(clientData, carType);
	}
	

	/**
	 * @Description:司机抢单
	 * @author hufan
	 * @since 2.5.6
	 */
	@Override
	public String driverGrabOrder(String requestData,PublishCarType carType) {
		
		if(carType == null) {
			return null;
		}
		if(carType == PublishCarType.SPECIAL) {
			return specialGrabOrderService.userGrabOrder(requestData);
		}
		
		return taxiGrabOrderService.driverGrabOrder(requestData);
	}

	/**
	 * 
	 * @Description:taxi取消订单
	 * @author hufan
	 * @since 2.5.6
	 */
	@Override
	public String taixCancelOrder(String requestData) {
		return taxiCancelOrderService.cancelOrder(requestData);
	}
	
}
